package com.pingan.service.impl;

import com.pingan.mapper.LogMapper;
import com.pingan.pojo.SysLog;
import com.pingan.service.LogService;
import com.pingan.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;

    @Override
    public List<SysLog> getLogList(SysLog sysLog) {
        return logMapper.getLogList(sysLog);
    }

    @Override
    public int doDeleteLog(Integer[] ids) {
        return logMapper.doDeleteLog(ids);
    }

    @Override
    public SysLog getLogDesc(Integer id) {
        return logMapper.getLogDesc(id);
    }

    @Async
    @Override
    public void saveLog(SysLog sysLog) {
        logMapper.saveLog(sysLog);
    }

    @Override
    public String getExportParams(SysLog sysLog) {
        String sign = UUID.randomUUID().toString().replaceAll("-","");
        RedisUtil.setRedisMap(sign,sysLog);
        return sign;
    }

    @Override
    public SysLog doExport(String sign) {
        Object redisMap = RedisUtil.getRedisMap(sign);
        return (SysLog) redisMap;
    }
}
